<?php
/**
 * Created by PhpStorm.
 * User: acker
 * Date: 21-06-08
 * Time: 下午6:25
 */

namespace App\Models;
use Illuminate\Database\Eloquent\Model;


class AdminRoleModel extends Model
{

    /**
     * 集团管理表
     *
     * @var string
     */
    protected $table = 'admin_roles';

    /**
     * 主键
     *
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * 该模型是否被自动维护时间戳
     *
     * @var bool
     */
    public $timestamps = false;

    /**
     * @var array
     */
    protected $fillable = [

    ];

    /**
 * @return array
 */
    protected function selectOptions(){
        $data_array =array();
        $data = self::get();
        foreach($data as $k=>$v){
            $data_array[$v['id']] = $v['name'];
        }
        return $data_array;
    }

    /**
     * @param $where_filed
     * @param $where_val
     * @param string $filed
     * @return string
     */
    protected function selectValue($where_filed,$where_val,$filed = 'name'){
        $list = self::where($where_filed,$where_val)->select($filed)->first();
        if(!empty($list)){
            return $list[$filed];
        }else{
            return "";
        }
    }

}
